<#import "/spring.ftl" as spring/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<#include "../head.ftl"/>
    <title>业务跟踪</title>
<#include "addPageSetting.ftl"/>
    <script type="text/javascript">
        var formSetting = {
            title: "操作登记",
            module: 'save',
            columns: formColumnSetting,
            form: {
                'url': '<@spring.url "/business/declaOpRec/getOpCount"/>',
                'data': function () {},
                'ajaxForm': {
                    success: function (data) {
                        var sbFlag = true;
                        var saveRec = function(){
                            $.ajax({
                                       url: '<@spring.url "/business/declaOpRec/saveRecord"/>',
                                       data: $("form").serialize(),
                                       method: 'post',
                                       async: false,
                                       success: function (_data) {
                                           if (_data.result) {
                                               parent.closeGridAndShowMsg(_data.msg);
                                           } else {
                                               layer.alert(_data.msg);
                                           }
                                       }
                                   });
                        };
                        if (data.result) {
                            var recCount = parseInt(data.msg);
                            if(recCount > 0){
                                var curOpDecript = $("input[name=recItemCode]").next().val();
                                layer.confirm("系统已有【"+ curOpDecript +"】记录，是否重复增加", {
                                    btn: ['是', '否'] //按钮
                                }, function () {
                                    console.log("同意重复提交");
                                    saveRec();
                                }, function () {
                                    sbFlag = false;
                                });
                            }else {
                                saveRec();
                            }
                        } else {
                            layer.msg("错误的操作项目，请重新选择");
                        }
                    }
                }
            },
            buttons: {
//                custom: buttonSetting
            }
        };
        $(document).ready(function () {
            $("#formTable").mrdForm(formSetting);
            $("input[name=otherRecItem]").parent().parent().hide();
        });
    </script>
</head>
<body>
<div id="formTable"></div>
</body>
</html>
